'use strict';

/**
 * @ngdoc function
 * @name htmsMobileApp.controller:MainCtrl
 * @description
 * # MainCtrl
 * Controller of the htmsMobileApp
 */
angular.module('htmsMobileApp')
  .controller('MainCtrl', function ($scope,CustomHttp,Authentication) {


    $scope.closeTitleMsg = function(type,id){
      CustomHttp.get("/api/bumentixing/message/doRead?"+type+"="+id).success(function (data) {
        var result =data;
      });
    };

    CustomHttp.get("/api/bumentixing/message/"+Authentication.getUser().type+"/"+Authentication.getUser().id).success(function (data) {
      var result = [];
      var result2 = [];
      var isDd;
      for(var i =0;i<data.length;i++){
        isDd=true;

        angular.forEach(data[i],function(value,key){
          if(key=="alertDubanId"){
            result.push(data[i]);
            isDd=false;
          }
        });

        if(isDd){ result2.push(data[i]);}
      }
      $scope.titleInfo= result;
      $scope.qtInfo = result2
    });

    $scope.comprehensive={};
    CustomHttp.get("/api/bumentixing/yinhuan/"+Authentication.getUser().type+"/"+Authentication.getUser().id).success(function (data) {
      $scope.comprehensive.major = data[0];
      $scope.comprehensive.general = data[1];
      $scope.comprehensive.rectifMajor = data[2];
      $scope.comprehensive.rectifGeneral = data[3];
    });

    $scope.enterprise={};
    CustomHttp.get("/api/bumentixing/entBaseInfo/"+Authentication.getUser().type+"/"+Authentication.getUser().id).success(function (data) {
      $scope.enterprise.unreported = data[0];
      $scope.enterprise.wait = data[1];
      $scope.enterprise.waitChange = data[2];
    })

    $scope.grade={};
    CustomHttp.get("/api/bumentixing/rating/"+Authentication.getUser().type+"/"+Authentication.getUser().id).success(function (data) {
      $scope.grade = data[0];
    });

  });
